from django.contrib.auth.models import User
from django.shortcuts import render
from django.views import View


class RegisterView(View):
    """用户注册"""
    def get(self, request):
        """提供用户注册页面"""
        return render(request, 'register.html')
    def post(self, request):
        """处理用户注册"""
        # 1. 获取数据
        username = request.POST.get('username')
        password = request.POST.get('password')

        User.objects.create_user(username=username, password=password)

        return render(request, 'index.html')


